#!/bin/sh

# DHCP event handler
case "$1" in
    bound|renew)
        # Configure IP address and netmask
        ifconfig "$interface" "$ip" netmask "$subnet" up

        # Add default gateway
        if [ -n "$router" ]; then
            while route del default gw 0.0.0.0 dev "$interface" 2>/dev/null; do :; done
            route add default gw "$router" dev "$interface"
        fi

        # Update DNS servers
        if [ -n "$dns" ]; then
            echo "nameserver $dns" > /etc/resolv.conf
        fi
        ;;
esac
